const inquirer = require('inquirer')

const createAction = async (name,args)=>{
   
    const projectName = name
    const projectOption = args
    // const answer = await inquirer.prompt([
    //     /* Pass your questions in here */
    //     {
    //         type:'input',//这个问题的类型
    //         name: 'username',//用该变量接收input的内容
    //         message:'your name',
    //     },{
    //         type:'list',
    //         name:'hobby',
    //         message:'你的爱好',
    //         choices:['music','paint','movie']
    //     },{
    //         type:'confirm',
    //         name:'isOk',
    //         message:'是否正确',
    //     }
    // ])
    const p =[{
        type:'list',
        name:'framwork',
        message:'node 框架',
        choices:['koa','express','egg']
    }]
    const answer = await inquirer.prompt(p)
    if(answer.framwork == 'koa'){
        
    }
    console.log(answer)
}


const configAction = (name,args)=>{
    console.log(name)
    console.log(args)
}

const { exec } = require("child_process");

function templateAction(name) {
  // 这是模板项目的仓库地址
  const url = "git@gitee.com:lagoufed/lagoufed-e-task.git";
  // 克隆项目
  exec(`git clone ${url} ${name}`, (error, stdout, stderr) => {
    if (error) {
      console.log(error);
      process.exit();
    }
    console.log("Success");
    process.exit();
  });
}
module.exports = {createAction,configAction,templateAction}